﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XMLSpreadGear.Core;

namespace XMLSpreadGear.Templates
{
   public class Column:BaseElement
    {

  public Column(string strlocalname)
            : base(strlocalname)
        {

        }

  public Column(string strlocalname,string caption,
        bool autoFitWidth,
        bool hidden,
        ulong index,
        ulong span,
        string styleID,
        double width)
            : this(strlocalname)
        {

      this.Caption=caption;
      this.AutoFitWidth =autoFitWidth;
      this.Hidden= hidden;
      this.Index=index;
      this.Span=span;
      this.StyleID=styleID;
      this.Width=width;

            
        }

        string m_Caption = string.Empty;
        bool? m_AutoFitWidth;
        bool? m_Hidden;
        ulong? m_Index;
        ulong? m_Span;
        string m_StyleID;
        double? m_Width;


        public string Caption
        {
            get { return m_Caption; }
            set { m_Caption = value; }
        } 
         public bool? AutoFitWidth
        {
            get { return m_AutoFitWidth; }
            set { m_AutoFitWidth = value; }
        }
         public bool? Hidden
        {
            get { return m_Hidden; }
            set { m_Hidden = value; }
        }
         public ulong? Index
        {
            get { return m_Index; }
            set { m_Index = value; }
        }
         public ulong? Span
        {
            get { return m_Span; }
            set { m_Span = value; }
        }
         public string StyleID
        {
            get { return m_StyleID; }
            set { m_StyleID = value; }
        }
         public double? Width
        {
            get { return m_Width; }
            set { m_Width = value; }
        }


         internal protected override IDictionary<string, string> RegisterAttributes()
         {
             IDictionary<string, string> dic = new Dictionary<string, string>();
             if(!string.IsNullOrEmpty(this.Caption))
                dic.Add("Caption", this.Caption);

             if(this.AutoFitWidth != null)
                 dic.Add("AutoFitWidth", this.AutoFitWidth.ToByte().ToString());

             if(this.Hidden !=null)
                 dic.Add("Hidden", this.Hidden.ToByte().ToString());

             if(this.Index != null)
                dic.Add("Index", this.Index.ToString());

             if(this.Span != null)
                dic.Add("Span", this.Span.ToString());

             if(!string.IsNullOrEmpty(this.StyleID))
                dic.Add("StyleID", this.StyleID);

             if(this.Width != null)
                dic.Add("Width", this.Width.ToString());

             return dic;
         }

         internal protected override IDictionary<string, string> RegisterElements()
         {
             IDictionary<string, string> dic = new Dictionary<string, string>();
             
             return dic;
         }

         protected override void SetDefaults()
         {
             return;
         }

         internal override string GetAttributeNamespace()
         {
             return Contstants.SpredsheetAttributePrefix;
         }

         internal override string GetAttributeNamespaceURI()
         {
             return Contstants.SpredsheetAttributeNamespace;
         }
    }
}
